import _isFunction from "lodash/isFunction";
import { mapCustomize } from "../utils/customize";

var defaultLayout = function defaultLayout() {
  return import("../layouts/DefaultLayout");
};

export function loadLayout(layoutName) {
  if (mapCustomize.has({
    module: 'cpaas-front',
    feature: 'layout',
    key: layoutName
  })) {
    var layout = mapCustomize.get({
      module: 'cpaas-front',
      feature: 'layout',
      key: layoutName
    });
    return _isFunction(layout && layout.component) ? layout.component : defaultLayout;
  }

  return defaultLayout;
}
export function setLayout(layoutName, layout) {
  mapCustomize.set({
    module: 'cpaas-front',
    feature: 'layout',
    key: layoutName,
    data: {
      component: layout
    }
  });
}